package org.small.shop.phone.api.process.goodsappraises.service;

import java.util.List;

import org.small.shop.phone.api.process.goodsappraises.mapper.TblWxGoodsAppraisesMapper;
import org.small.shop.phone.api.process.goodsappraises.pojo.TblWxGoodsAppraisesVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class TblWxGoodsAppraisesServiceImpl implements TblWxGoodsAppraisesService {

	@Autowired
	private TblWxGoodsAppraisesMapper tblWxGoodsAppraisesMapper;

	@Override
	public TblWxGoodsAppraisesVo selectAllApprByGoodsid(TblWxGoodsAppraisesVo tblWxGoodsAppraisesVo) {

		Integer currentPage = tblWxGoodsAppraisesVo.getCurrentPage();
		Integer perPage = tblWxGoodsAppraisesVo.getPerPage();
		if (currentPage != null && currentPage != -1 && perPage != null) {
			tblWxGoodsAppraisesVo.setStartNum((currentPage - 1) * perPage);
		} else {
			tblWxGoodsAppraisesVo.setStartNum(0);
			tblWxGoodsAppraisesVo.setPerPage(10);
		}
		List<TblWxGoodsAppraisesVo> list = tblWxGoodsAppraisesMapper.selectAllApprByGoodsid(tblWxGoodsAppraisesVo);

		Integer count = tblWxGoodsAppraisesMapper.selectAllApprByGoodsidCount(tblWxGoodsAppraisesVo.getGoodsId());
		tblWxGoodsAppraisesVo.setTotalNum(count);
		tblWxGoodsAppraisesVo.setList(list);

		return tblWxGoodsAppraisesVo;
	}

}
